home *** CD-ROM | disk | FTP | other *** search
- Path: phcoms4.seri.philips.nl!news
- From: Marc Keijsers <keijsers@sce.philips.nl>
- Newsgroups: comp.lang.c
- Subject: Re: Problem with arrays
- Date: 30 Jan 1996 13:41:57 GMT
- Organization: Philips Semiconductors B.V.
- Message-ID: <4el775$g6i@phcoms4.seri.philips.nl>
- References: <4ejtia$6id@sifon.cc.mcgill.ca>
- NNTP-Posting-Host: 130.144.63.217
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.05 9000/735)
- X-URL: news:4ejtia$6id@sifon.cc.mcgill.ca
-
- >
- > I'm currently writing a program using tries to store words. For bulding my trie, I have defined the following struct:
- >
- >typedef struct nodebox NODEBOX, *TRIE
- >
- >struct nodebox{
- >{ int letters[100];
- > TRIE subtree[100];
- >};
- >
- >Then, I declare variables as tries in certain functions. But here's the problem: before inserting any letter in the trie, I expect the
- >
- >elements in the array letters to be all zeros( '\0' ) like in a normal empty >array. But instead, the elements of this arrays are weird
-
- (Please, Please, don't use the word trIe if you mean tree. It makes
- this story utterly confusing.)
-
- This is completely NORMAL. If you declare an array, its values are
- undefined. You will have to write a routine which initialises your
- structure with '/0' (plain '0' will do also).
-
-
- >
- >numbers like 25678. It bothers me since I assume that they are '\0' in my >insert function. I really don't know what's going wrong.
- >
- >If you have any idea or solutions, I'd be very graceful if you could e-mail me; >I'm stuck.
- >
- >Thanks a lot.
- >
- the values like 25678 are almost completely at random. Your data-structure
- is placed somewhere in your computers memory banks. The values IN the array are
- values which just happen to be in that particular memory-location.
-
- Hope this helps,
-
- Marc
- --
- __ __ _____ _____ _____ |
- | \/ | / _ \ | _ \ / \ | Marc Keijsers
- | | | _ | | / | <--< | keijsers@ehv.sc.philips.com
- |_|\/|_| \_/ \_/ |__|__\ \_____/ | Eindhoven, The Netherlands
-
-